package cn.NewsServlet;

import cn.NewsDao.NewsDao1;
import cn.NewsDaoImpl.NewsDaoImpl1;
import cn.NewsService.NewsService;
import cn.NewsServiceImpl.NewsServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
@WebServlet("/newsdel")
public class DelAjaxServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        int newId = Integer.parseInt(req.getParameter("id"));
        NewsService newsService = new NewsServiceImpl();
        NewsDao1 newsDao1 = new NewsDaoImpl1();

        //resp.setCharacterEncoding("text/html;charset=UTF-8");
        PrintWriter printWriter=resp.getWriter();
        if (newsDao1.delete(newId)) {
            printWriter.print(1);
        } else {
            printWriter.print(-1);
        }
        printWriter.flush();
        printWriter.close();



    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {




    }
}
